package com.reader.api.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author liujianqing
 * @date 2018/10/25
 */
@Configuration
public class AliPayConfig {
    private static final Logger logger = LoggerFactory.getLogger(AliPayConfig.class);

    @Value("${ali.pay.appId}")
    private String appId;
    @Value("${ali.pay.appPrivateKey}")
    private String appPrivateKey;
    @Value("${ali.pay.charset}")
    private String charset;
    @Value("${ali.pay.alipayPublicKey}")
    private String alipayPublicKey;
    @Value("${ali.pay.format}")
    private String format;
    @Value("${ali.pay.serverUrl}")
    private String serverUrl;
    @Value("${ali.pay.signType}")
    private String signType;

    @Bean(name = "alipayClient")
    public AlipayClient alipayClient() {
        AlipayClient alipayClient = new DefaultAlipayClient(serverUrl,
                appId, appPrivateKey, format, charset, alipayPublicKey, signType);
        return alipayClient;
    }
}
